package com.kaishengit.web;


import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.kaishengit.dao.PDao;
import com.kaishengit.entity.Project;

public class EditProjectServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	public void destroy() {
	}

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String pname=request.getParameter("pname");
		String pdescripe=request.getParameter("pdescripe");
		PDao pdao=new PDao();
		HttpSession session=request.getSession();
		String nowprojectid=(String)session.getAttribute("nowprojectid");
		Project project=pdao.findById(nowprojectid);
		project.setPname(pname);
		project.setPdescripe(pdescripe);
		pdao.update(project);
		List<Project> plist=pdao.findAll();
		session.setAttribute("plist",plist);
		response.sendRedirect("tran.jspx?name=main");
		
	}
	
	public void init() throws ServletException {
	}

}
